*****************************************
*** LANE AND SCHOENHERR CITE AND SWAY ***
*****************************************

* Purpose:
*	- Replicate Table B7 in supplemental appendix

* Data Sources:
*	- Analysis2DataStata.dta

* Run on:
*	- StataNow/SE 19.5 for Mac (Apple Silicon) on macOS Sequoia 15.1.1

* Associated codebook:
*	- Analysis2Codebook.pdf

*****************************************
*****************************************
*****************************************

*************************************
*** STEP 0: SET WORKING DIRECTORY ***
*************************************

cd ""
********************************
*** STEP 1: READ IN THE DATA ***
********************************

use "Analysis2DataStata.dta"

*************************************
*** STEP 2: RENAME VARIABLE NAMES ***
*************************************

* stata hates when variable names end with log

rename petUnnamedCiteLog logPetUnnamedCite
rename petMajCallOutLog logPetMajCallOut
rename petNotMajOpinLog logPetNotMajOpin
rename respUnnamedCiteLog logRespUnnamedCite
rename respMajCallOutLog logRespMajCallOut
rename respNotMajOpinLog logRespNotMajOpin

******************************************
*** STEP 3: CREATE A FEW NEW VARIABLES ***
******************************************

generate logPetNumCites = log(petNumCites + 1)
generate logRespNumCites = log(respNumCites + 1)

*************************************
*** STEP 2: CLUSTERED BY JUSTICE  ***
*************************************

*** TABLE B7, COLUMN 2

logit voteWithPet c.logPetUnnamedCite##c.ideoAlign c.logPetMajCallOut##c.ideoAlign c.logPetNotMajOpin##c.ideoAlign c.logRespUnnamedCite##c.ideoAlign c.logRespMajCallOut##c.ideoAlign c.logRespNotMajOpin##c.ideoAlign pastExpertise logPetNumCites logRespNumCites petExperienceAdvantage sgParty lcDisagreement amiciNet helpOSG netStatus oaQuestDiff, cluster(justice)

est store logit
estat ic

est restore logit
margins, at(logPetUnnamedCite=(0) ideoAlign=(-2.909)) ///
at(logPetUnnamedCite=(0.693147) ideoAlign=(-2.909)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetUnnamedCite=(0) ideoAlign=(2.918)) ///
at(logPetUnnamedCite=(0.693147) ideoAlign=(2.918)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetNotMajOpin=(0) ideoAlign=(2.918)) ///
at(logPetNotMajOpin=(0.693147) ideoAlign=(2.918)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetNotMajOpin=(0) ideoAlign=(-2.909)) ///
at(logPetNotMajOpin=(0.693147) ideoAlign=(-2.909)) vce(unconditional) post
test _b[1._at] = _b[2._at]

*********************************
*** STEP 3: CLUSTERED BY TERM ***
*********************************

*** TABLE B7, COLUMN 3

logit voteWithPet c.logPetUnnamedCite##c.ideoAlign c.logPetMajCallOut##c.ideoAlign c.logPetNotMajOpin##c.ideoAlign c.logRespUnnamedCite##c.ideoAlign c.logRespMajCallOut##c.ideoAlign c.logRespNotMajOpin##c.ideoAlign pastExpertise logPetNumCites logRespNumCites petExperienceAdvantage sgParty lcDisagreement amiciNet helpOSG netStatus oaQuestDiff,  cluster(term)

est store logit
estat ic

est restore logit
margins, at(logPetUnnamedCite=(0) ideoAlign=(-2.909)) ///
at(logPetUnnamedCite=(0.693147) ideoAlign=(-2.909)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetUnnamedCite=(0) ideoAlign=(2.918)) ///
at(logPetUnnamedCite=(0.693147) ideoAlign=(2.918)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetNotMajOpin=(0) ideoAlign=(2.918)) ///
at(logPetNotMajOpin=(0.693147) ideoAlign=(2.918)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetNotMajOpin=(0) ideoAlign=(-2.909)) ///
at(logPetNotMajOpin=(0.693147) ideoAlign=(-2.909)) vce(unconditional) post
test _b[1._at] = _b[2._at]

**********************************
*** STEP 4: CLUSTERED BY ISSUE ***
**********************************

*** TABLE B7, COLUMN 4

logit voteWithPet c.logPetUnnamedCite##c.ideoAlign c.logPetMajCallOut##c.ideoAlign c.logPetNotMajOpin##c.ideoAlign c.logRespUnnamedCite##c.ideoAlign c.logRespMajCallOut##c.ideoAlign c.logRespNotMajOpin##c.ideoAlign pastExpertise logPetNumCites logRespNumCites petExperienceAdvantage sgParty lcDisagreement amiciNet helpOSG netStatus oaQuestDiff,  cluster(issue)

est store logit
estat ic

est restore logit
margins, at(logPetUnnamedCite=(0) ideoAlign=(-2.909)) ///
at(logPetUnnamedCite=(0.693147) ideoAlign=(-2.909)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetUnnamedCite=(0) ideoAlign=(2.918)) ///
at(logPetUnnamedCite=(0.693147) ideoAlign=(2.918)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetNotMajOpin=(0) ideoAlign=(2.918)) ///
at(logPetNotMajOpin=(0.693147) ideoAlign=(2.918)) vce(unconditional) post
test _b[1._at] = _b[2._at]

est restore logit
margins, at(logPetNotMajOpin=(0) ideoAlign=(-2.909)) ///
at(logPetNotMajOpin=(0.693147) ideoAlign=(-2.909)) vce(unconditional) post
test _b[1._at] = _b[2._at]





